package com.iknow.util;

public class SpringDynamics extends Dynamics
{
  private float mDamping;
  private float mFriction;
  private float mStiffness;

  private float calculateAcceleration()
  {
    float f2;
    float f1 = getDistanceToLimit();
    if (f1 != 0F)
      f2 = f1 * this.mStiffness - this.mDamping * this.mVelocity;
    while (true)
    {
      return f2;
      f2 = -this.mFriction * this.mVelocity;
    }
  }

  protected void onUpdate(int paramInt)
  {
    float f1 = paramInt / 1000.0F;
    float f2 = calculateAcceleration();
    this.mPosition += f1 * this.mVelocity + f1 * f1 * 0.5F * f2;
    this.mVelocity += f2 * f1;
  }

  public void setFriction(float paramFloat)
  {
    this.mFriction = paramFloat;
  }

  public void setSpring(float paramFloat1, float paramFloat2)
  {
    this.mStiffness = paramFloat1;
    this.mDamping = (2F * paramFloat2 * (float)Math.sqrt(paramFloat1));
  }
}